package com.xxxx.system.index.Controller;
import java.net.URI;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.Before;
import org.junit.Test;
public class HdfsTest{
	//获取hadoop FileSystem对象
	private FileSystem fs=null;
	/**
	 * 初始化环境变量
	 * @author kesh
	 */
	@Before
	public void init() throws Exception{
		/**
		 * new URL("hdfs://192.168.6.128:9000")
		 * new Configuration():使用hadoop默认配置
		 * "root":登陆用户
		 */
		fs=FileSystem.get(new URI("hdfs://192.168.241.128:9000"),new Configuration(),"root");
	}
	/**
	 * 创建目录
	 */
	@Test
	public void testMkdir() throws Exception{
		boolean flag=fs.mkdirs(new Path("/testMkdir"));
		System.out.println(flag?"创建成功":"创建失败");
	}
}